package com.loto.insurance.oem.web.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.loto.insurance.oem.web.db.mapper.PolicyFlowMapper;
import com.loto.insurance.oem.web.db.mapper.PolicyInfoAirMapper;
import com.loto.insurance.oem.web.db.mapper.PolicyInfoMapper;
import com.loto.insurance.oem.web.db.mapper.PolicyInfoTravelMapper;
import com.loto.insurance.oem.web.entity.PolicyInfo;
import com.loto.insurance.oem.web.entity.PolicyInfoAir;
import com.loto.insurance.oem.web.entity.PolicyInfoTravel;

@Service
public class PolicyInfoService {

  @Autowired
  PolicyInfoAirMapper policyInfoAirMapper;

  @Autowired
  PolicyInfoTravelMapper policyInfoTravelMapper;

  @Autowired
  PolicyInfoMapper policyInfoMapper;

  @Autowired
  PolicyFlowMapper policyFlowMapper;

  public List<PolicyInfoAir> getPolicyInfoAirById(long orderId) {
	return policyInfoAirMapper.findPolicyInfoById(orderId);
  }

  public List<PolicyInfoTravel> getPolicyInfoTravelById(long orderId) {
	return policyInfoTravelMapper.findPolicyInfoById(orderId);
  }

  // 保单list
  public long findAllPoliciesByCustCount(Map<String, Object> params) {
	return policyInfoMapper.findAllPoliciesByCustPagerCount(params);
  }

  public List<PolicyInfo> findAllPoliciesByCust(Map<String, Object> params) {
	return policyInfoMapper.findAllPoliciesByCustPager(params);
  }
  
  public long findAllPoliciesCount(Map<String, Object> params) {
	return policyInfoMapper.findAllPoliciesPagerCount(params);
  }

  public List<PolicyInfo> findAllPolicies(Map<String, Object> params) {
	return policyInfoMapper.findAllPoliciesPager(params);
  }

  // 问题保单list
  public long findProblemPoliciesByCustCount(long custId) {
	return policyInfoMapper.findProblemPoliciesByCustPagerCount(custId);
  }

  public List<PolicyInfo> findProblemPoliciesByCust(Map<String, Object> params) {
	return policyInfoMapper.findProblemPoliciesByCustPager(params);
  }

  // 查看问题保单问题描述
  public String findLastestFlowByIdType(int insType, long policyId) {
	Map<String, Object> params = new HashMap<String, Object>();
	params.put("insType", insType);
	params.put("policyId", policyId);
	return policyFlowMapper.findLastestFlowByIdType(params);
  }
}
